//加载代理商基本信息
window.onload = function(){
	var param2 = "/agency/findAgUserInfo";
	var method2 = "post";//请求方式post/get
	getAgentMsg2(param2,method2);

	$(".isEditInfo").find(".name").text(dataResult2.data.agCompayName);
	$(".isEditInfo").find(".wwwUrl").text(dataResult2.data.agCompayUrl);
	$(".isEditInfo").find(".address").text(dataResult2.data.agCompayAddress);
	$(".isEditInfo").find(".contacts").text(dataResult2.data.agPerson);
	$(".isEditInfo").find(".telephone").text(dataResult2.data.agPhone);
	$("#name").val(dataResult2.data.agCompayName);
	$("#wwwUrl").val(dataResult2.data.agCompayUrl);
	$("#address").val(dataResult2.data.agCompayAddress);
	$("#contacts").val(dataResult2.data.agPerson);
	$("#telephone").val(dataResult2.data.agPhone);
}

//基本信息编辑与取消
$('.EditInfo').on("click",function(){
	$(".isEditInfo").toggleClass('ng-hide');
	$(".isEditInfoHide").toggleClass('ng-hide');
});
//取消编辑基本信息
$('#cancelEditInfo').on("click",function(){
	$(".isEditInfo").toggleClass('ng-hide');
	$(".isEditInfoHide").toggleClass('ng-hide');
});
//修改基本信息

$("#modifyAgent").on("click",function(){
	var name = $('#name').val();//公司名称 agCompayName
	var wwwUrl = $('#wwwUrl').val();//公司网址 agCompayUrl
	var address = $('#address').val();//公司地址 agComapyAddress
	var contacts = $('#contacts').val();//联系人 agPerson
	var telephone = $('#telephone').val();//手机号码 agPhone
	param = "/agency/sysManage/fundaInformation";
	method = "post";//请求方式post/get
	datas = {agCompayName:name,agCompayUrl:wwwUrl,agComapyAddress:address,agPerson:contacts,agPhone:telephone};
	getAgentMsg(param,method,datas);
//	console.log(dataResult);
	layer.msg(dataResult.msg,{time:2*1000},function() {
		window.location.reload();
	});
	
});

//密码信息编辑与取消
$(".EditPwd").on("click",function(){
	$(".isEditPwdHide").toggleClass('ng-hide');
	$(".isEditPwd").toggleClass('ng-hide');
});
//取消编辑密码
$('#cancleEditPwd').on("click",function(){
	$(".isEditPwdHide").toggleClass('ng-hide');
	$(".isEditPwd").toggleClass('ng-hide');
});


//修改密码确定按钮
$("#resetPWD").on("click",function(){
	var oldPasswd = $('#oldPasswd').val();
	var newPasswd = $('#newPasswd').val();
	var newPasswd2 = $('#newPasswd2').val();
	if(!oldPasswd || !newPasswd || !newPasswd2){
		layer.msg("所有密码均不能为空");
		return false;
	}
	if(newPasswd != newPasswd2){
		layer.msg("两次输入的新密码不一致");
		return false;
	}
	var param1 = "/sys/password";
	var method1 = "post";//请求方式post/get
	var datas1 = {oldPassword:oldPasswd,newPassword:newPasswd};
	getAgentMsg(param1,method1,datas1);
//console.log(dataResult);
if(dataResult.code == 0){
	logout();
}else{
	layer.msg(dataResult.msg);
	return false;
}
		
	
});



